package com.itheima.controller;

import com.itheima.pojo.User;
import com.itheima.response.ResponseResult;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping
    public ResponseResult<User> findAll(){
        return ResponseResult.okResult(userService.findAll());
    }

    @PostMapping
    public ResponseResult<User> add(@RequestBody User user){
        return ResponseResult.okResult(userService.add(user));
    }
}
